package com.rency.mtds.manager.spi.enums;

import io.swagger.annotations.ApiModel;
import lombok.Getter;
import lombok.ToString;

import java.util.Arrays;
import java.util.Optional;

/**
 * 数据库类型
 * @author: caiyu.ren
 * Created on 2019/9/3 10:15
 * @version: V1.0.0
 * @since JDK 11
 */
@ApiModel("数据库类型")
@Getter
@ToString
public enum DbType {

    MYSQL("mysql", "MySQL数据库"),
    ORACLE("oracle", "Oracle数据库"),
    ;

    private String code;

    private String msg;

    DbType(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static DbType get(String code){
        Optional<DbType> optional = Arrays.stream(DbType.values()).filter(kind -> kind.getCode().equalsIgnoreCase(code)).findFirst();
        return optional.orElse(null);
    }
}
